package com.liyj.heroadmin.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Title：ElasticSearch 配置
 * @Description: 后期要将 主机的 用户名 端口 http接口
 * @Param: 无
 * @Return: 无
 * @author <a href="mail to: herocnhb@163.com" rel="nofollow">李亚军</a>
 * @CreateDate: 2019-12-23
 * @update: [01][日期2019-12-23日] [李亚军][无]
 */
@Configuration
public class ESClient {


    @Value("${elasticsearch.host}")
    public String host;

    @Value("${elasticsearch.port}")
    public Integer port;


    @Bean
    public RestHighLevelClient elasticsearchClient() {

        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(host, port, "http")));
        return client;
    }


}